XM/XenAPI: Add cdrom support when creating domains by xm through Xen API.
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 13 May 2008 08:48:55 +0000 (09:48 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 13 May 2008 08:48:55 +0000 (09:48 +0100)
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
tools/python/xen/xm/xenapi_create.py

index 7c45564461997d9f654e66cf900f0cdc7f926e23..13339501901ab53378e6fa31216bf8bb13869afd 100644 (file)
@@ -31,6 +31,7 @@ import xen.util.xsm.xsm as security
 import sys
 import os
 import traceback
+import re
 
 def log(_, msg):
     #print "> " + msg
@@ -707,9 +708,11 @@ class sxp2xml:
             = get_child_by_name(vbd_sxp, "mode") != "w" \
               and "RO" or "RW"
         vbd.attributes["device"] \
-            = get_child_by_name(vbd_sxp, "dev")
+            = re.sub(":cdrom$", "", get_child_by_name(vbd_sxp, "dev"))
         vbd.attributes["bootable"] = "1"
-        vbd.attributes["type"] = "disk"
+        vbd.attributes["type"] \
+            = re.search(":cdrom$", get_child_by_name(vbd_sxp, "dev")) \
+              and "CD" or "disk"
         vbd.attributes["qos_algorithm_type"] = ""
 
         return vbd